Summary and Quiz on the Go Language Basics

Close our discussion on the Go language essentials section, along with a quiz to test our concepts.

We'll cover the following

Summary#

In this section, we learned the essential parts of the Go language. This included handling errors, using Go concurrency, taking advantage of Go's testing framework, and an introduction to Go's newest feature, generics. The skills acquired in this section are essential for all future sections.

We should now possess the ability to read Go code contained in the rest of the book. In addition, this section has given us the necessary skills to write our own Go code. We’ll use these skills to manipulate files in the filesystem, execute commands on remote machines, and build RPC services that can do a myriad of tasks. We'll build chatbots in order to do chat-based operations (ChatOps) and write software to extend kubernetes. The learnings here are truly foundational.

Quiz#

10

What inputs wouldn’t yield an error in the following code?

func TestGreet(*testing.T) {
    name := "Sam"
    want := "Hello Sam"

    got, err := Greet(name)
    if got != want || err != nil {
        t.Fatalf("TestGreet(%s): got %q/%v, want %q/nil", name, got, err, want)
    }
}
Your Answer
A)

Sam

Correct Answer
B)

Hello Sam

C)

Both A and B

D)

Hello

Question 10 of 1010 attempted

Adding Type Parameters to Struct Types

Introduction